﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MetaSearcher
{
    class AviaSales
    {
        public string GetResp_AviaSales(String date, String from, String from_rus, String to, String to_rus)
        {
            System.Text.Encoding encode = System.Text.Encoding.Unicode;
            //String URL = "http://nano.aviasales.ru/searches/39961822?marker=google.org&with_request=true&origin_iata=" + from + "&destination_iata=" + to + "&origin=" + from_rus + "&destination=" + to_rus + "&depart_date=" + date + "&oneway=1&adults=1&children=0&infants=0&trip_class=1";
            String URL = "http://avia.turizm.ru/cgi-bin/avia/search.pl?search=1&go=sirena&act=aviasearch&r=226895&direct=1&main_search=1&wdaye=&wdays=&from=%CC%EE%F1%EA%E2%E0&to=%C1%E5%F0%EB%E8%ED&dates=04.04.2012";
            System.Net.WebRequest reqGET = System.Net.WebRequest.Create(URL);
            
            //Получение ответа на get-запрос
            reqGET.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1");
            
            System.Net.WebResponse resp = reqGET.GetResponse();
            
            //Запись ответа
            System.IO.Stream stream = resp.GetResponseStream();
            
            System.IO.StreamReader sr = new System.IO.StreamReader(stream);
            
            System.Text.Encoding dg=sr.CurrentEncoding;
            Console.WriteLine(dg);
            string s = sr.ReadToEnd();
            return s;
        }
        /*public static void Main(String[] args)
        {
            
            AviaSales av = new AviaSales();
            String sv = "";
            sv=av.GetResp_AviaSales("2012-04-25", "MOW", "Москва", "BER", "Берлин");
            FileStream fs = new FileStream("d:\\abv33.txt", FileMode.OpenOrCreate, FileAccess.Write); 
            StreamWriter sw = new StreamWriter(fs); 
            sw.WriteLine(sv); 
            sw.Close();
            
            Console.WriteLine(sv);
            Console.ReadKey();
        } */
    }
}
